<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>Product Detail</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" type="text/css" href="${ctx}/css/template/round_corner.css"/>
  <script type="text/javascript" src="/js/jquery-1.7.1.js"></script>
  <script type="text/javascript">
    function adjustIframe()
    {
       var win = document.getElementById('descIframe');
       if(!win){
    	   return;
       }
   	   if (win.contentDocument && win.contentDocument.body.offsetHeight) 
   	   {
   	    	win.height = win.contentDocument.body.offsetHeight; 
   	    	win.width =win.contentDocument.body.offsetWidth;
   	   }else if(win.Document && win.Document.body.scrollHeight)
   	   {
   	    	win.height = win.Document.body.scrollHeight;
   	    	win.width=win.Document.body.scrollWidth;
   	   }    	
    }  
    
    $(document).ready(function(){
    	$('#addCartBtn').click(function(){
    		$('#prodForm').attr('action',"/nag/cart/addItem.do?p=<s:property value='p'/>");
    		$('#prodForm').submit();
    	});
    	$('#buyNowBtn').click(function(){
    		$('#prodForm').attr('action',"/nag/cart/listItem.do?p=<s:property value='p'/>");
    		$('#prodForm').submit();
    	});
    });
  </script>
</head>
<body>
   <div style="margin:10px 0;">
   	  <t:simpleContainer template="round_corner">
   	  <table>
   	     <tbody>
   	        <tr>
   	            <td><img style="width:320px;height:200px; border:0;" src="<s:property value='product.pictures[0].path'/>"/></td>
   	            <td>&nbsp;</td>
   	            <td>
   	            <form id="prodForm" action="" method="post">
   	            <table>   	            
   	              <tbody>
   	                  <tr>
   	                  	<td><span class="title"><h1><s:property default="name" value='product.name'/></h1></span><s:property value='product.desc'/>
   	                  	</td>
   	                  </tr>
   	                  <tr><td><input type="button" id="addCartBtn" value="Add to cart"/></td>
   	                  </tr>
   	                  <tr><td><input type="button" id="buyNowBtn" value="Buy it Now"/></td>
   	                  </tr>
   	              </tbody>
   	            </table>
   	            </form>
   	            </td>
   	        </tr>
   	     </tbody>
   	  </table>   	 
      </t:simpleContainer>      
      <div style="width:100%;height:100%;"">
         <iframe id="descIframe" style="width:942px;padding:0;margin:0;border:0" src="/nag/piece/detail.do?p=<s:property value='p'/>" scrolling="no"
            onload="adjustIframe();">			
         </iframe>
      </div>    
   </div>   
</body>
</html>